#define DIR_PIN 52 //output pin for direction of stepper motor
#define STEP_PIN 53 //output pin used to tell motor to move a step

void setup() {
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
}

//If an input is 3+ volts it's HIGH, if it's 2- volts it's LOW
//for an output, 5 volts is HIGH, 0 volts is LOW
void loop() {
    rotate( 7500, .1);
    delay(1000);
    rotate( -7500, .1);
    delay(1000);
}

void rotate(int steps, float speed) {
  //rotate a specific number of microsteps (8 microsteps per step) - (negative for reverse movement)
  //speed is any number from .01 -> 1 with 1 being fastest - Slower is stronger
  int dir = (steps > 0)? HIGH:LOW;
  steps = abs(steps);
  
  digitalWrite(DIR_PIN, dir);

  if(speed > 1) {
    speed = 1;
  }

  float usDelay = (1/speed) * 70;

  for(int i=0; i < steps; i++){
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(usDelay);
  }
}
